<template>
    <div style="background-color: cadetblue;">
        {{ x }}
    </div>
</template>

<script setup lang='ts'>
// import { ref, reactive } from 'vue'
import { ref, getCurrentInstance } from 'vue'

let x = ref('')
const instance = getCurrentInstance()
// 接收多个参数
instance?.proxy?.$bus.on('*', (type: any, str: any) => {
    console.log('事件名为:', type)
    console.log('接收到的内容为:', str)
    x = str
})

const Bus = (str: any) => {
    console.log(str);

}
//事件监听接收单个参数
instance?.proxy?.$bus.on('on-click', Bus)
//事件监听取消
instance?.proxy?.$bus.off('on-click', Bus)
//事件监听清除所有事件
instance?.proxy?.$bus.all.clear()
</script>

<style scoped lang="scss"></style>